package com.jetinno.bean;

import android.support.annotation.StringRes;
import android.view.View;

import com.jetinno.utils.ResourcesUtil;

import java.io.Serializable;

/**
 * Created by zhangyuncai on 2021/11/8.
 */
public class ItemBean extends SerialBean implements Serializable, PopupItemTextInterface {
    private transient int itemNameRes;
    private transient boolean isChecked;
    private transient View.OnClickListener onClickListener;

    public ItemBean() {
    }

    public ItemBean(@StringRes int itemNameRes) {
        this.itemNameRes = itemNameRes;
    }

    public ItemBean(@StringRes int itemNameRes, View.OnClickListener onClickListener) {
        this.itemNameRes = itemNameRes;
        this.onClickListener = onClickListener;
    }

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }

    public ItemBean setChecked2(boolean checked) {
        isChecked = checked;
        return this;
    }

    public void setItemNameRes(int itemNameRes) {
        this.itemNameRes = itemNameRes;
    }

    public int getItemNameRes() {
        return itemNameRes;
    }

    public View.OnClickListener getOnClickListener() {
        return onClickListener;
    }

    public ItemBean setOnClickListener(View.OnClickListener onClickListener) {
        this.onClickListener = onClickListener;
        return this;
    }

    @Override
    public String getText() {
        if (itemNameRes <= 0) {
            return "";
        }
        return ResourcesUtil.getString(itemNameRes);
    }

}
